package org.example.clouddemo.controller.app;


import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.example.clouddemo.bean.common.param.PayOrderParam;
import org.example.clouddemo.bean.common.param.PayParam;


import org.example.clouddemo.service.common.PaymentService;
import org.example.common.annotation.IgnoreAuth;

import org.example.common.response.ApiResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Api(tags = "支付接口")
@RestController("appPayController")
@RequestMapping("/api/app/pay")
public class PayController {

    @Autowired
    private PaymentService paymentService;

    @ApiOperation(value = "支付", notes = "支付")
    @PostMapping("checkPayable")
    @IgnoreAuth
    public ApiResult checkStock(@Validated @RequestBody PayParam param) {
        return ApiResult.success(paymentService.pay(param.getOrder(), param.getAmount()));

    }

    @ApiOperation(value = "支付订单", notes = "支付订单")
    @PostMapping("payOrder")
    @IgnoreAuth
    public ApiResult payOrder(@Validated @RequestBody PayOrderParam param) {
        return ApiResult.success(paymentService.payOrder(param));

    }
}
